package com.msb.mallsearch.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Auther: xixifeng
 * @Date: 2022/10/18 - 10 - 18 - 14:24
 * @Description: com.msb.mallsearch.config
 * @version: 1.0
 */
@Configuration
public class MallElasticSearchConfiguration {

    /**
     * ElasticSearch的配置类
     */
    @Bean
    public RestHighLevelClient restHighLevelClient(){
        RestClientBuilder builder = RestClient.builder(new HttpHost("192.168.56.100", 9200, "http"));
        RestHighLevelClient client = new RestHighLevelClient(builder);
        return client;
    }


    /**
     * 测试保存文档 ,设置RequestOptions
     */
    public static final RequestOptions COMMON_OPTIONS;
    static {

        RequestOptions.Builder builder = RequestOptions.DEFAULT.toBuilder();

        COMMON_OPTIONS=builder.build();
    }


}
